package ${cfg.ServiceImpl};

import ${cfg.Service}.${entity}Service;
import ${cfg.Entity}.${entity};
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.SneakyThrows;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import ${cfg.Req}.${entity}Req;
import ${cfg.Resp}.${entity}Resp;
import ${cfg.DataService}.${entity}DataService;
import personal.zq.practice.sys.service.utils.PageUtils;
/**
* ${table.comment} 服务实现类
*
* @author ${author}
* @since ${cfg.time}
*/
@Service
public class ${entity}ServiceImpl implements ${entity}Service {
@Autowired
${entity}DataService dataService;

@SneakyThrows
@Override
public void create(${entity}Req req) {
${entity} dto = ${entity}.class.newInstance();
BeanUtils.copyProperties(req, dto);
dataService.save(dto);
}

@SneakyThrows
@Override
public void update(${entity}Req req) {
${entity} dto = ${entity}.class.newInstance();
BeanUtils.copyProperties(req, dto);
dataService.updateById(dto);
}

@Override
public void del(Long id) {
dataService.removeById(id);
}

@SneakyThrows
@Override
public IPage<${entity}Resp> qry(${entity}Req req) {
    ${entity} dto = ${entity}.class.newInstance();
    BeanUtils.copyProperties(req, dto);
    QueryWrapper queryWrapper = new QueryWrapper();
    IPage<${entity}> iPage = new Page<>(req.getCurrentPage(), req.getPageSize());
    iPage = dataService.page(iPage, queryWrapper);
    return PageUtils.convertPage(iPage, ${entity}Resp.class);
    }

    @SneakyThrows
    @Override
public ${entity}Resp getDetail(Long id) {
    ${entity} dto = dataService.getById(id);
    ${entity}Resp resp = ${entity}Resp.class.newInstance();
    BeanUtils.copyProperties(dto, resp);
    return resp;
    }
    }
